import { http } from './request'

// 登录接口
export const LogIn = (userName, password) => {
  return http.post('/api/v1/auth/manager_login', { userName, password })
}

// 用户列表接口
export const getPersonList = (obj) => {
  return http.get('/api/v1/admin/user', obj)
}
//用户名搜索
export const getuserName = (word) => {
  return http.get(`/api/v1/admin/user?page=1&userName=${word}`)
}
// 删除用户
export const getDeleteUser = (id) => {
  return http.delete(`/api/v1/admin/user/${id}`)
}
// 修改用户信息
export const getUpdateUser = (id, data) => {
  return http.put(`/api/v1/admin/user/${id}`, data)
}
// 开锁解锁
export const getLock = (id, isLocked) => {
  return http.put(`/api/v1/admin/user/${id}`, { isLocked: isLocked })
}
// 分页功能
export const getPage = (page) => {
  return http.get(`/api/v1/admin/user?page=${page}`)
}
// 上传图片文件
export const postFile = (file) => {
  return http.post('/api/v1/common/upload_file', file)
}

// 获取轮播图分类列表
export const getBannerList = (page, per) => {
  return http.get(`/api/v1/admin/bannercategory?page=${page}&per=${per}`)
}
// 上传轮播图分类列表
export const postAddBanner = (data) => {
  return http.post('/api/v1/admin/bannercategory', data)
}
// 修改轮播图
export const putModifyBanner = (id, data) => {
  return http.put(`/api/v1/admin/bannercategory/${id}`, data)
}
// 删除轮播图列表中的数据
export const deleteDelBanner = (id) => {
  return http.delete(`/api/v1/admin/bannercategory/${id}`)
}

// 获取轮播图管理列表
export const getManageBannerLi = (data) => {
  console.log(data)
  return http.get(`/api/v1/admin/banner`, { params: { ...data } })
}
// 删除轮播图管理列表
export const deleteManageBannerDel = (id) => {
  return http.delete(`/api/v1/admin/banner/${id}`)
}
// 新增轮播图管理列表
export const postManageBannerAdd = (data) => {
  return http.post('/api/v1/admin/banner', data)
}
// 修改轮播管理列表
export const putManageBannerModify = (id, data) => {
  return http.put(`/api/v1/admin/banner/${id}`, data)
}
// 订单管理-列表
export const orderList = (page, per) =>
  http.get(`/api/v1/admin/order/?page=${page}&per=${per}`)
//订单管理-详情
export const orderDetail = (str) =>
  http.get(`/api/v1/admin/orderdetail?where=${str}`)
//新增公告
export const NewNotice = (form) => {
  return http.post('/api/v1/admin/notice', form)
}

//公告列表
export const NoticeList = (obj) => {
  return http.get('/api/v1/admin/notice', obj)
}
//根据name查找
export const NoticeListName = (word) => {
  return http.get(`/api/v1/admin/notice?page=1&name=${word}`)
}
//page改变
export const NoticeListPage = (page) => {
  return http.get(`/api/v1/admin/notice?page=${page}`)
}
//删除公告
export const NoticeDelete = (id) => {
  return http.delete(`/api/v1/admin/notice/${id}`)
}
//修改公告
export const NoticeUpdata = (id, data) => {
  return http.put(`/api/v1/admin/notice/${id}`, data)
}
// 获取修改公告信息
export const NoticeInfo = (id) => {
  return http.get(`/api/v1/admin/notice/${id}`)
}

// 商品列表
export const getGoodsList = (params) => {
  return http.get('/api/v1/admin/product', { params: params })
}
